import {post,del,fetch} from './http'

// 购物车下单
export const placeAnOrder= function (data) {
  return new Promise((resolve, reject) => {
      fetch('/rubbish-server/order/publish', data).then(res =>{
          resolve(res)
      }).catch(err => {
          reject(err)
      })
  })
}
// 分页查询订单（除购物车）
export const getOrderList = function (data) {
  return new Promise((resolve, reject) => {
      del('/rubbish-server/order/query', data).then(res =>{
          resolve(res)
      }).catch(err => {
          reject(err)
      })
  })
}
// 批量删除购物车
export const delOrderBatch = function (data) {
    return new Promise((resolve, reject) => {
        del('/rubbish-server/order/delete/shopping', data).then(res =>{
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// 创建
export const orderCreate = function (data) {
    return new Promise((resolve, reject) => {
        fetch('/rubbish-server/order/create', data).then(res =>{
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// 加入购物车
export const addShopping = function (data) {
    return new Promise((resolve, reject) => {
        post('/rubbish-server/order/add/shopping', data).then(res =>{
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
// 获取
export const getOrderById = function (data) {
    return new Promise((resolve, reject) => {
        fetch('/rubbish-server/order/'+ data).then(res =>{
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

// 根据用户id获取订单
export const getOrderByUserId = function (data) {
    return new Promise((resolve, reject) => {
        fetch('/rubbish-server/order/get/shopping'+ data, data).then(res =>{
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}